import Vue from 'vue'
import Router from 'vue-router';
import VueRouter from 'vue-router'

Vue.use(Router);

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/Home.vue'),
    // 档案知识化
    children: [{
      path: '/knowMan',
      component: () => import('../components/knowMan/index.vue'),
      redirect: '/knowMan/homePage',
      children: [
        // 知识首页
        {
          path: 'homePage',
          component: () => import('../components/knowMan/homepage/homepage.vue'),
          meta: { title: '知识首页'},
        },
        // 知识发布
        {
          path: 'issue',
          component: () => import('../components/knowMan/issue/issue.vue'),
          meta: { title: '知识发布'},
        },
        {
          path: 'audit',
          component: () => import('../components/knowMan/issue/audit.vue'),
          meta: { title: '知识发布审核'},
        },
         // 知识管理
         {
          path: 'tabLibrary',
          component: () => import('../components/knowMan/manage/tabLibrary.vue'),
          meta: { title: '标签库'},
        },
        {
          path: 'category',
          component: () => import('../components/knowMan/manage/category.vue'),
          meta: { title: '知识分类'},
        },
        // 知识发布考核
        {
          path: 'personIssue',
          component: () => import('../components/knowMan/report/personIssue.vue'),
          meta: { title: '知识发布量统计'},
        },
        {
          path: 'unitIssue',
          component: () => import('../components/knowMan/report/unitIssue.vue'),
          meta: { title: '单位发布量统计'},
        },
        // 知识应用
        {
          path: 'archive',
          component: () => import('../components/knowMan/usage/archive.vue'),
          meta: { title: '档案知识化'},
        },
      ]
    }] 
  }
]

const router = new VueRouter({
  routes
})

export default router
